import { SET_TAB, CLEAR_TAB, SET_SCROLLY, SET_ADDRESS} from "../actionType"
import { IAction } from "../../interface"

const initState: any = {
    address: '千峰沈阳',
    screenY: 0
}

export const addressReducer = (state = initState, action: IAction) => {
    const { type, payload } = action
    switch (type) {
        case SET_TAB:
            return { ...state, tab: payload }
            break;
        case CLEAR_TAB:
            return { ...state, tab: '' }
            break;
        case SET_SCROLLY:
            return { ...state, tab: payload }
            break;
        case SET_ADDRESS:
            return { ...state, address: payload }
            break;
        default:
            return state
    }
}